package com.heisenhub.system.controller;


import com.heisenhub.common.db.controller.AbstractController;
import com.heisenhub.system.dto.DeptDto;
import com.heisenhub.system.entity.Dept;
import com.heisenhub.system.enums.SystemEnums;
import com.heisenhub.system.query.DeptQuery;
import com.heisenhub.system.service.IDeptService;
import com.heisnenhub.common.module.exception.RRException;
import com.heisnenhub.common.module.inter.BusinessTypeEnumsInter;
import com.heisnenhub.common.module.utils.Api;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * <p>
 * 部门表 前端控制器
 * </p>
 *
 * @author sen
 * @since 2023-12-24
 */
@RestController
@RequestMapping("/dept")
public class DeptController extends AbstractController<Dept, DeptDto, DeptQuery, IDeptService > {




//    @Override
//    protected ISuperService<Dept, DeptQuery> getService() {
//        return deptService;
//    }




   // @PreAuthorize("businessTypeEnums.permission")

   //@PreAuthorize(value = "hasAuthority(T(com.heisenhub.system.enums.SystemEnums).DEPT)")
   @GetMapping("listAll")
    public Api list() {
       return Api.ok(service.listNotDelAll());
    }

    @PostMapping("listAllpost")
    public Api listAllpost( @Validated @RequestBody DeptDto addDto) {
        return Api.ok(service.listNotDelAll());
    }


    /**
     * 获取 部门树
     * @return
     */
    @GetMapping(value = "tree" ,name = "获取部门树")
    public Api tree() {
        return Api.ok(service.deptTree());
    }


    @Override
    public BusinessTypeEnumsInter getBusinessTypeEnums() {
        return SystemEnums.DEPT;
    }

}
